
getPending();
function getPending() {
    var i=0;
    $("#pending").empty();
    $.getJSON("../connection_list/" + userid, function(data) {
        $.each(data, function(key, value) {
            if (value.type == "pending") {
                $("#pending").append(value.name + "<input type=\"submit\" class=\"epicButton\" value=\"Accept\" \n\
                            onclick=\"accepta(" + value.id + ")\" /><br />");
                i++;
            }
            $("#toggle").html("Friend requests: "+i);
        });
    });
}
$("#toggle").click(function() {
    $("#pending").slideToggle("slow");
});

function accepta(id) {
    $.post("../connection_accept/" + id, function() {
        getPending();
    });
}